package edc;

/**
 * It's very important to note that this class stores the actual data plus the code.
 * So actually a single object represents an encoded data not only the code.
 *
 * @author vpopov
 */
abstract public class Code {

	final private String data;
	private String encodedData;

	public Code(String data) {
		this.data = data;
	}

	public String getData() {
		return data;
	}

	@Override
	public String toString() {
		return getEncodedData();
	}

	@Override
	public boolean equals(Object obj) {
		// TODO: implement
		return false;
	}

	private String getEncodedData() {
		if (encodedData == null) {
			encodedData = encodeData();
		}

		return encodedData;
	}

	abstract protected String encodeData();
}
